#include "TitleState.h"

#include "OptionsState.h"
#include "HighScoreState.h"
#include "../items/ChangeStateButton.h"
#include "../items/StopFrameButton.h"

TitleState* TitleState::theTitleState = NULL;

TitleState::TitleState(Frame *aFrame) {
    this->theTitle = "Hangman Game";
	this->theFrame = aFrame;
}

TitleState::~TitleState() {
}

void TitleState::populate() {
	ChangeStateButton *toOptions = new ChangeStateButton('1', "Play", OptionsState::getInstance(this->theFrame));
    ChangeStateButton *toHighScores = new ChangeStateButton('2', "High Scores", HighScoreState::getInstance(this->theFrame));
    StopFrameButton *stopFrame = new StopFrameButton('3', "Exit");
    this->theItems.push_back(toOptions);
    this->theItems.push_back(toHighScores);
    this->theItems.push_back(stopFrame);
}

TitleState& TitleState::getInstance(Frame *aFrame) {
	if(TitleState::theTitleState == NULL) {
		TitleState::theTitleState = new TitleState(aFrame);
		TitleState::theTitleState->populate();
		aFrame->insertState(TitleState::theTitleState);
	}
    return *TitleState::theTitleState;
}
